public class Musica{
  int liga;
  Sample musica, track1, track2;
  Musica(){
    track1 = new Sample("musicas//1.aiff");
    track2 = new Sample("musicas//2.aiff");
    liga=1;
    
  }
  
  void start(){
    if(musica==null || !musica.isPlaying()){
      musica = trackSelect();
      musica.play();
      musica.setVolume(.4);
    }
    
    if(liga==1)
      musica.setSpeed(1);
    else
      musica.setSpeed(0);
  }
  
  void stop(){
    musica.stop();
    
  }
  
  Sample trackSelect(){
    int select = (int)(random(2));
    Sample track=null;
    
    switch(select){
      case 0:
      track=track1;
      break;
      
      case 1:
      track=track2;
      break;
    }
    return track;
  }
}
